STM is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing. It functions as an alternative to lock-based synchronization, and is typically implemented in a lock-free way. A transaction in this context is a piece of code that executes a series of reads and writes to shared memory. These reads and writes logically occur at a single instant in time. Immediate states are not visible to other transactions.
STM may use read barriers to mediate access to shared memory locations such as object fields and class fields. The read barriers allow STM to detect when fields are read in a transaction while being written to in another transaction. Read barriers involve execution of additional instructions which can adversely impact the performance of a program.
Attempts to improve STM techniques in the past involved performing immutable field optimization. Immutable fields are fields that are not modified once an object has been initialized. Fields may refer to object field or static (class) fields. An STM system can improve performance significantly by avoiding the overheads of utilizing read barriers on accesses to immutable fields.
Immutable field optimization, however, rely on explicit “final” annotations by a programmer or knowledge of which standard classes are immutable. Many other fields are implicitly final because they are never updated after object initialization. While a compiler can be configured to detect such fields through whole program analysis, languages that allow dynamic class loading, such as Java, make whole program analysis infeasible.